#include<iostream>
#include<string>

using namespace std;

class A
{
public:
    A (int x)
    {
        a = x;
        cout << "a的构造函数" << a <<endl;
    }
    ~A()
    {
        cout << "a的析构函数" << endl;
    }
    int a;
};

class B : virtual public A
{
public:
    B():A(10)
    {
        cout << "b的构造函数" << endl;
    }
    ~B()
    {
        cout << "b的析构函数" << endl;
    }
};

class C : virtual public A
{
public:
    C():A(20)
    {
        cout << "c的构造函数" << endl;
    }
    ~C()
    {
        cout << "c的析构函数" << endl;
    }
};

class D : public B, public C
{
public:
    D():A(30)
    {
        cout << "d的构造函数" << endl;
    }
    ~D()
    {
        cout << "d的析构函数" << endl;
    }
};

int main()
{
    D d;
    cout << d.a<< endl;
    return 0;
}
